package com.bridgeintelligent.tag.bulkload.service.time;

import com.alibaba.fastjson.JSON;
import com.bridgeintelligent.tag.bulkload.api.EsDateModel;
import com.bridgeintelligent.tag.mapper.EsTimeMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
@Slf4j
public class EsDateServiceImpl implements IEsDateService {

    @Autowired
    private EsTimeMapper mapper;

    @Override
    public Map<String, String> symbolRelation(String indexId) {
        List<EsDateModel> timeList = mapper.indexAllTime(indexId);
        Map<String, String> map = timeList.stream().collect(Collectors.toMap(EsDateModel::getSymbol, EsDateModel::getEsSymbol));
        log.info("索引：{} 获取ES日期-标识集合：{}", indexId,JSON.toJSONString(map));
        return map;
    }
}
